<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Flow: flow::net_flow::error Namespace Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">Flow<span id="projectnumber">&#160;2.0.0</span>
   </div>
   <div id="projectbrief">Flow project: Full implementation reference.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceflow.html">flow</a></li><li class="navelem"><a class="el" href="namespaceflow_1_1net__flow.html">net_flow</a></li><li class="navelem"><a class="el" href="namespaceflow_1_1net__flow_1_1error.html">error</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">flow::net_flow::error Namespace Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Namespace containing the <a class="el" href="namespaceflow_1_1net__flow.html" title="Flow module containing the API and implementation of the Flow network protocol, a TCP-inspired stream...">net_flow</a> module's extension of <a class="el" href="namespaceboost_1_1system.html" title="We may add some ADL-based overloads into this namespace outside flow.">boost.system</a> error conventions, so that Flow network protocol API can return codes/messages from within its own new set of error codes/messages.  
<a href="namespaceflow_1_1net__flow_1_1error.html#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classflow_1_1net__flow_1_1error_1_1Category.html">Category</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">The <a class="el" href="namespaceboost_1_1system.html" title="We may add some ADL-based overloads into this namespace outside flow.">boost.system</a> category for errors returned by the <code><a class="el" href="namespaceflow_1_1net__flow.html" title="Flow module containing the API and implementation of the Flow network protocol, a TCP-inspired stream...">net_flow</a></code> Flow module.  <a href="classflow_1_1net__flow_1_1error_1_1Category.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="enum-members" name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:a18e13de77b119ea0f2be411490859482"><td class="memItemLeft" align="right" valign="top">enum class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482">Code</a> { <br />
&#160;&#160;<a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482affac5d80b4e72f2e55bbbfadce2efd2e">S_NODE_NOT_RUNNING</a> = 1
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482aac3ec8d83192e9cd271376fce4001e99">S_CANNOT_CONNECT_TO_IP_ANY</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482abb79e941df00b67a8631a9361ee5a4d1">S_INVALID_SERVICE_PORT_NUMBER</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a2c42b01b60ebe4834e9be3933ce94cb6">S_PORT_TAKEN</a>
, <br />
&#160;&#160;<a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a0eac39cc62ef841927a2f69a3c04db4e">S_INTERNAL_ERROR_PORT_NOT_TAKEN</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a1975df7ed76c42660cbdc6039d5c70c5">S_OUT_OF_PORTS</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ae90ff1c87f2393dd6b14232b159f02b2">S_INTERNAL_ERROR_PORT_COLLISION</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891">S_CONN_RESET_BAD_PEER_BEHAVIOR</a>
, <br />
&#160;&#160;<a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482aa220d89e1d0e34bab02ed2fc7512be9b">S_CONN_REFUSED</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a074451c0bc9f5ae37e0c8fbe82677090">S_CONN_TIMEOUT</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a138a08bb4d41be4cdbc6311a1a617cf4">S_CONN_RESET_BY_OTHER_SIDE</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a3c1dc923491f5e20763fc27d025665d4">S_CONN_RESET_TOO_MANY_REXMITS</a>
, <br />
&#160;&#160;<a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a8ad7147a3e4e63313c7a5954790cd458">S_SEQ_NUM_ARITHMETIC_FAILURE</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a891201a96c5838bbb24cc9ed08b47765">S_SEQ_NUM_IMPLIES_CONNECTION_COLLISION</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a5d57c6a6029d7c6a9e5442ac72ac7a6b">S_NODE_SHUTTING_DOWN</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a35606f4143e15dbe6bc03a543599dec8">S_USER_CLOSED_ABRUPTLY</a>
, <br />
&#160;&#160;<a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ae643fd244bd1d6b483295cb9f356b0ae">S_EVENT_SET_CLOSED</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a3f2c29ade2454001982c033a37fd9c79">S_EVENT_SET_IMMUTABLE_WHEN_WAITING</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a8f3a13ffefc4897da606c86e60a4422f">S_EVENT_SET_EVENT_ALREADY_EXISTS</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a96f464959b6ce918048a2167c23f1c0b">S_EVENT_SET_EVENT_DOES_NOT_EXIST</a>
, <br />
&#160;&#160;<a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482adccb025a96014a74a1435481ec2b58ac">S_EVENT_SET_DOUBLE_WAIT_OR_POLL</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a5cbb0762dc20632c76db479f40237492">S_EVENT_SET_NO_EVENTS</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a3e273da0f7d2f231dbfaab8d07fd5ecd">S_EVENT_SET_RESULT_CHECK_WHEN_WAITING</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a9a2cbc62120ca52c1f7e695b56b2bdcd">S_CONN_METADATA_TOO_LARGE</a>
, <br />
&#160;&#160;<a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ad7b8da59bb61205572fe985c29863e58">S_STATIC_OPTION_CHANGED</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a5e0c2b54a5427bc09ecf0dee603ce450">S_OPTION_CHECK_FAILED</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab92ec3b2b78d74acf0fda0786f601df5">S_WAIT_INTERRUPTED</a>
, <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab835895723a7d71c964b84e0f0b78c3c">S_WAIT_USER_TIMEOUT</a>
<br />
 }</td></tr>
<tr class="memdesc:a18e13de77b119ea0f2be411490859482"><td class="mdescLeft">&#160;</td><td class="mdescRight">All possible errors returned (via <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">flow::Error_code</a> arguments) by <a class="el" href="namespaceflow_1_1net__flow.html" title="Flow module containing the API and implementation of the Flow network protocol, a TCP-inspired stream...">flow::net_flow</a> functions/methods.  <a href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482">More...</a><br /></td></tr>
<tr class="separator:a18e13de77b119ea0f2be411490859482"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a6d35c37eb70a494bb27aa807c41de176"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a6d35c37eb70a494bb27aa807c41de176">make_error_code</a> (<a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482">Code</a> err_code)</td></tr>
<tr class="memdesc:a6d35c37eb70a494bb27aa807c41de176"><td class="mdescLeft">&#160;</td><td class="mdescRight">Given a <code>Code</code> <code>enum</code> value, creates a lightweight <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">flow::Error_code</a> (a/k/a <a class="el" href="namespaceboost_1_1system.html" title="We may add some ADL-based overloads into this namespace outside flow.">boost.system</a> <code>error_code</code>) representing that error.  <a href="namespaceflow_1_1net__flow_1_1error.html#a6d35c37eb70a494bb27aa807c41de176">More...</a><br /></td></tr>
<tr class="separator:a6d35c37eb70a494bb27aa807c41de176"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >Namespace containing the <a class="el" href="namespaceflow_1_1net__flow.html" title="Flow module containing the API and implementation of the Flow network protocol, a TCP-inspired stream...">net_flow</a> module's extension of <a class="el" href="namespaceboost_1_1system.html" title="We may add some ADL-based overloads into this namespace outside flow.">boost.system</a> error conventions, so that Flow network protocol API can return codes/messages from within its own new set of error codes/messages. </p>
<h3>Synopsis</h3>
<div class="fragment"><div class="line"><span class="comment">// Assign a code from net_flow&#39;s custom error code set -- to a *general* Error_code.</span></div>
<div class="line"><a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">flow::Error_code</a> code = <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482aa220d89e1d0e34bab02ed2fc7512be9b">flow::net_flow::error::Code::S_CONN_REFUSED</a>;</div>
<div class="line"><span class="comment">// code contains the int equivalent of S_CONN_REFUSED enum value; and a category pointer for your new</span></div>
<div class="line"><span class="comment">// new code set to which S_CONN_REFUSED belonds.  So it&#39;s about the size of errno plus a pointer.</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// Yet we have nice OO access to the equivalents of `errno` and `strerror(errno)`:</span></div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;General error value = [&quot;</span> &lt;&lt; code.value() &lt;&lt; <span class="stringliteral">&quot;]; msg = [&quot;</span> &lt;&lt; code.message() &lt;&lt; <span class="stringliteral">&quot;].\n&quot;</span>;</div>
<div class="line"><span class="comment">// And we can throw an std::exception (`catch{}` can log the exception&#39;s .what() which will contain</span></div>
<div class="line"><span class="comment">// the numeric value, the human message, and the optional context string).</span></div>
<div class="line"><span class="keywordflow">throw</span> <a class="code hl_class" href="classflow_1_1error_1_1Runtime__error.html">flow::error::Runtime_error</a>(code, <span class="stringliteral">&quot;Additional context info here!&quot;</span>);</div>
<div class="ttc" id="aclassflow_1_1error_1_1Runtime__error_html"><div class="ttname"><a href="classflow_1_1error_1_1Runtime__error.html">flow::error::Runtime_error</a></div><div class="ttdoc">An std::runtime_error (which is an std::exception) that stores an Error_code.</div><div class="ttdef"><b>Definition:</b> <a href="error_2error_8hpp_source.html#l00047">error.hpp:49</a></div></div>
<div class="ttc" id="anamespaceflow_1_1net__flow_1_1error_html_a18e13de77b119ea0f2be411490859482aa220d89e1d0e34bab02ed2fc7512be9b"><div class="ttname"><a href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482aa220d89e1d0e34bab02ed2fc7512be9b">flow::net_flow::error::Code::S_CONN_REFUSED</a></div><div class="ttdeci">@ S_CONN_REFUSED</div><div class="ttdoc">Other side refused connection.</div></div>
<div class="ttc" id="anamespaceflow_html_a29eaaa9d0fac4ce87d8b969222dbed09"><div class="ttname"><a href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">flow::Error_code</a></div><div class="ttdeci">boost::system::error_code Error_code</div><div class="ttdoc">Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...</div><div class="ttdef"><b>Definition:</b> <a href="common_8hpp_source.html#l00508">common.hpp:508</a></div></div>
</div><!-- fragment --><h3>Discussion</h3>
<p >The contents of this <code>namespace</code> is one instance (and model example) for how one can easily create their own simple error code set <code>enum</code> (and corresponding string messages) and hook it into the flexible, yet maximally fast, <a class="el" href="namespaceboost_1_1system.html" title="We may add some ADL-based overloads into this namespace outside flow.">boost.system</a> error facility. Another example (a peer of ours) would be boost.asio's error code set. See <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">flow::Error_code</a> doc header for a top-down summary of the Flow-used-and-recommended error reporting system.</p>
<p >For <a class="el" href="namespaceboost_1_1system.html" title="We may add some ADL-based overloads into this namespace outside flow.">boost.system</a> experts wondering whether there is support for <code>error_condition</code> equivalence (i.e., the ability to compare a given <code>flow::error::error_code</code> to a more general <code>boost::system::error_condition</code>), currently the answer is no, there isn't. We may add <code>error_condition</code>s as <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">Error_code</a> usage patterns emerge over time.</p>
<h3>Summary of implementation</h3>
<p >This summarizes how we got the Synopsis above to work. Replicate this in other modules as desired.</p><ol type="1">
<li>Define new code set <code>enum</code> in your own namespace (recommend <code>error</code> sub-namespace of your module) in a new header file (recommend name based on namespace name). Say we call it E.hpp.</li>
<li>Also in E.hpp: Declare <code><a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a6d35c37eb70a494bb27aa807c41de176" title="Given a Code enum value, creates a lightweight flow::Error_code (a/k/a boost.system error_code) repre...">make_error_code()</a></code> prototype right next to it.</li>
<li>Also in E.hpp: Define <code>is_error_code_enum&lt;&gt;</code> specialization in <code><a class="el" href="namespaceboost_1_1system.html" title="We may add some ADL-based overloads into this namespace outside flow.">boost::system</a></code> namespace.</li>
<li>In E.cpp: Define a new, non-public, category class C, whose main part is a simple function mapping each <code>enum</code> value to its human message (<code>switch()</code>). Instantiate a single <code>static</code> instance of C, perhaps as a member: <code>C::S_C</code>.</li>
<li>Also in E.cpp: Implement the tiny boiler-plate <code><a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a6d35c37eb70a494bb27aa807c41de176" title="Given a Code enum value, creates a lightweight flow::Error_code (a/k/a boost.system error_code) repre...">make_error_code()</a></code> from step 2. It constructs a general <code>Error_code</code> with the <code>int</code> version of the custom-<code>enum</code> value passed to it; and with a reference to <code>C::S_C</code> from previous step, thus identifying both the code set and the individual code.</li>
</ol>
<p >Result: One can directly assign codes from your new <code>enum</code> to the general <code>Error_code</code> (a/k/a <code>boost::system::error_code</code>); see Synopsis above.</p>
<h3>Implementation discussion</h3>
<p >While <em>using</em> this error reporting system is simple and convenient, the internal implementation is (IMO) cryptic albeit fairly concise. I followed the guide:</p>
<p ><a href="http://blog.think-async.com/2010/04/system-error-support-in-c0x-part-4.html">http://blog.think-async.com/2010/04/system-error-support-in-c0x-part-4.html</a></p>
<p >Note that this isn't some random web page but rather a detailed a walkthrough by the author of <a class="el" href="namespaceboost_1_1system.html" title="We may add some ADL-based overloads into this namespace outside flow.">boost.system</a> (which includes <code>error_code</code>) itself. In addition, its author wrote boost.asio, which we use extensively in this implementation. Finally, boost.asio's own extension of the <code>error_code</code>/etc. system &ndash; for its own error reporting, which is API-wise quite similar to this one &ndash; can be seen (in boost.asio's largely headers-only implementation) to follow the above guide ~99% to the letter.</p>
<p >What's rather odd is that <a class="el" href="namespaceboost_1_1system.html" title="We may add some ADL-based overloads into this namespace outside flow.">boost.system</a>'s actual formal documentation, e.g.,</p>
<p ><a href="http://www.boost.org/doc/libs/1_50_0/libs/system/doc/index.html">http://www.boost.org/doc/libs/1_50_0/libs/system/doc/index.html</a>,</p>
<p >does not in any way explain how to implement all this properly. The above guide is not included in that official doc, nor is it linked. In fact, following the formal documentation without a supernatural (IMO) level of understanding of the author's intentions, would likely lead to the wrong implementation. Most visibly, for example, the docs say that <code>error_code</code> is for platform-dependent error codes; while <code>error_condition</code> is for portable error codes, or something very, very close to that. Well (I thought originally), Flow's errors ARE platform-independent, so I guess I should use <code>error_condition</code>s then! So originally, all the Flow APIs that reported errors took <code>Error_condition*</code> arguments, not <code>Error_code*</code> arguments. Only after some colleagues remarked that this appears wrong, and pointed out the above guide, did I realize that I did that wrong and switched to <code>Error_code</code>. In particular, the guide elucidates: <code>error_code</code> is to report a "low-level" or "system-level" specific error (not necessarily computer platform-dependent, as the formal doc might seem to say), while <code>error_condition</code> is something to (optionally) "check against" as a higher-level or more abstract piece of error handling logic. So in fact any original error should be an <code>error_code</code>, and <code>error_condition</code> is an <em>optional</em> layer one <em>might</em> add to help working with <code>error_code</code>s. </p>
</div><h2 class="groupheader">Enumeration Type Documentation</h2>
<a id="a18e13de77b119ea0f2be411490859482" name="a18e13de77b119ea0f2be411490859482"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a18e13de77b119ea0f2be411490859482">&#9670;&nbsp;</a></span>Code</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">enum class <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482">flow::net_flow::error::Code</a></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">strong</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>All possible errors returned (via <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">flow::Error_code</a> arguments) by <a class="el" href="namespaceflow_1_1net__flow.html" title="Flow module containing the API and implementation of the Flow network protocol, a TCP-inspired stream...">flow::net_flow</a> functions/methods. </p>
<p >These values are convertible to <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">flow::Error_code</a> (a/k/a <code>boost::system::error_code</code>) and thus extend the set of errors that <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">flow::Error_code</a> can represent.</p>
<p >When you add a value to this <code>enum</code>, also add its description to net_flow_error.cpp’s <a class="el" href="classflow_1_1net__flow_1_1error_1_1Category.html#ae01ad7da6ba4d494a5455a82fc03481e" title="Implements superclass API: given the integer error code of an error in this category,...">Category::message()</a>. This description must be identical to the description in the /// comment below, or at least as close as possible.</p>
<p >If, when adding a new revision of the code, you add a value to this <code>enum</code>, add it to the end. If, when adding a new revision of the code, you deprecate a value in this <code>enum</code>, do not delete it from this <code>enum</code>. Instead mark it as deprecated here and then remove it from Flow_category::message().</p>
<p >Errors that indicate apparent logic bugs (in other words, assertions that we were too afraid to write as actual <code>assert()</code>s) should be prefixed with <code>S_INTERNAL_ERROR_</code>, and their messages should also indicate "Internal error: ".</p>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000079">Todo:</a></b></dt><dd>Consider adding specific subclasses of <a class="el" href="classflow_1_1error_1_1Runtime__error.html" title="An std::runtime_error (which is an std::exception) that stores an Error_code.">flow::error::Runtime_error</a> for the key codes, like <code>WAIT_INTERRUPTED</code> and <code>USER_TIMEOUT</code>. In doing so, make sure there's an automated syntactic-sugary way of doing this, so that one need only add a code&lt;-&gt;class pair into some internal centralized mapping, automatically making system emit the proper exception class, defaulting to plain Runtime_error if not specially-mapped. </dd></dl>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482affac5d80b4e72f2e55bbbfadce2efd2e" name="a18e13de77b119ea0f2be411490859482affac5d80b4e72f2e55bbbfadce2efd2e"></a>S_NODE_NOT_RUNNING&#160;</td><td class="fielddoc"><p ><a class="el" href="classflow_1_1net__flow_1_1Node.html" title="An object of this class is a single Flow-protocol networking node, in the sense that: (1) it has a di...">Node</a> not running. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482aac3ec8d83192e9cd271376fce4001e99" name="a18e13de77b119ea0f2be411490859482aac3ec8d83192e9cd271376fce4001e99"></a>S_CANNOT_CONNECT_TO_IP_ANY&#160;</td><td class="fielddoc"><p >Cannot ask to connect to "any" IP address. Use specific IP address. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482abb79e941df00b67a8631a9361ee5a4d1" name="a18e13de77b119ea0f2be411490859482abb79e941df00b67a8631a9361ee5a4d1"></a>S_INVALID_SERVICE_PORT_NUMBER&#160;</td><td class="fielddoc"><p >Flow port number is not in the valid service port number range. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a2c42b01b60ebe4834e9be3933ce94cb6" name="a18e13de77b119ea0f2be411490859482a2c42b01b60ebe4834e9be3933ce94cb6"></a>S_PORT_TAKEN&#160;</td><td class="fielddoc"><p >Flow port already reserved. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a0eac39cc62ef841927a2f69a3c04db4e" name="a18e13de77b119ea0f2be411490859482a0eac39cc62ef841927a2f69a3c04db4e"></a>S_INTERNAL_ERROR_PORT_NOT_TAKEN&#160;</td><td class="fielddoc"><p >Internal error: Tried to return Flow port which had not been reserved. </p>
<dl class="section note"><dt>Note</dt><dd>By its definition (see above brief description), it can only be triggered by <a class="el" href="classflow_1_1net__flow_1_1Port__space.html#a9fe1be917ff7584ff587b5da5967127a" title="Return a previously reserved port (of any type).">Port_space::return_port()</a>. If one looks at all the calls to said method in practice, they'll note that it returning a truthy <code>*err_code</code> of any kind is unexpected to the point where it is an <code>assert()</code> failure, as least as of this writing. Therefore, <code>S_..._PORT_NOT_TAKEN</code> is indeed deserving of having the <code>INTERNAL_ERROR</code> prefix (meaning, it occurring implies a programming error inside library). As of this writing, unless <code>assert()</code>s are compiled out, it's not even possible for the error to get to the user (but that may change by removing some or all of those <code>assert()</code>s &ndash; in which case the error's naming matters more. Bottom line, it is an <code>..._INTERNAL_ERROR_...</code> until some condition in practice makes it possible that <a class="el" href="classflow_1_1net__flow_1_1Port__space.html#a9fe1be917ff7584ff587b5da5967127a" title="Return a previously reserved port (of any type).">Port_space::return_port()</a> failing that way is not a result of a programming error. </dd></dl>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a1975df7ed76c42660cbdc6039d5c70c5" name="a18e13de77b119ea0f2be411490859482a1975df7ed76c42660cbdc6039d5c70c5"></a>S_OUT_OF_PORTS&#160;</td><td class="fielddoc"><p >No more ephemeral Flow ports available. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482ae90ff1c87f2393dd6b14232b159f02b2" name="a18e13de77b119ea0f2be411490859482ae90ff1c87f2393dd6b14232b159f02b2"></a>S_INTERNAL_ERROR_PORT_COLLISION&#160;</td><td class="fielddoc"><p >Internal error: Ephemeral port double reservation allowed. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891" name="a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891"></a>S_CONN_RESET_BAD_PEER_BEHAVIOR&#160;</td><td class="fielddoc"><p >Connection reset because of unexpected/illegal behavior by the other side. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482aa220d89e1d0e34bab02ed2fc7512be9b" name="a18e13de77b119ea0f2be411490859482aa220d89e1d0e34bab02ed2fc7512be9b"></a>S_CONN_REFUSED&#160;</td><td class="fielddoc"><p >Other side refused connection. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a074451c0bc9f5ae37e0c8fbe82677090" name="a18e13de77b119ea0f2be411490859482a074451c0bc9f5ae37e0c8fbe82677090"></a>S_CONN_TIMEOUT&#160;</td><td class="fielddoc"><p >Other side did not complete connection handshake within the allowed time; perhaps no one is listening. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a138a08bb4d41be4cdbc6311a1a617cf4" name="a18e13de77b119ea0f2be411490859482a138a08bb4d41be4cdbc6311a1a617cf4"></a>S_CONN_RESET_BY_OTHER_SIDE&#160;</td><td class="fielddoc"><p >Other side reset an established connection. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a3c1dc923491f5e20763fc27d025665d4" name="a18e13de77b119ea0f2be411490859482a3c1dc923491f5e20763fc27d025665d4"></a>S_CONN_RESET_TOO_MANY_REXMITS&#160;</td><td class="fielddoc"><p >Connection reset because a packet has been retransmitted too many times. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a8ad7147a3e4e63313c7a5954790cd458" name="a18e13de77b119ea0f2be411490859482a8ad7147a3e4e63313c7a5954790cd458"></a>S_SEQ_NUM_ARITHMETIC_FAILURE&#160;</td><td class="fielddoc"><p >Other side has sent packets with inconsistent sequence numbers. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a891201a96c5838bbb24cc9ed08b47765" name="a18e13de77b119ea0f2be411490859482a891201a96c5838bbb24cc9ed08b47765"></a>S_SEQ_NUM_IMPLIES_CONNECTION_COLLISION&#160;</td><td class="fielddoc"><p >Other side has sent packet with sequence number that implies a port collision between two connections over time. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a5d57c6a6029d7c6a9e5442ac72ac7a6b" name="a18e13de77b119ea0f2be411490859482a5d57c6a6029d7c6a9e5442ac72ac7a6b"></a>S_NODE_SHUTTING_DOWN&#160;</td><td class="fielddoc"><p ><a class="el" href="classflow_1_1net__flow_1_1Node.html" title="An object of this class is a single Flow-protocol networking node, in the sense that: (1) it has a di...">Node</a> shutting down. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a35606f4143e15dbe6bc03a543599dec8" name="a18e13de77b119ea0f2be411490859482a35606f4143e15dbe6bc03a543599dec8"></a>S_USER_CLOSED_ABRUPTLY&#160;</td><td class="fielddoc"><p >User code on this side abruptly closed connection; other side may be informed of this. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482ae643fd244bd1d6b483295cb9f356b0ae" name="a18e13de77b119ea0f2be411490859482ae643fd244bd1d6b483295cb9f356b0ae"></a>S_EVENT_SET_CLOSED&#160;</td><td class="fielddoc"><p >Attempted operation on an event set, when that event set was closed. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a3f2c29ade2454001982c033a37fd9c79" name="a18e13de77b119ea0f2be411490859482a3f2c29ade2454001982c033a37fd9c79"></a>S_EVENT_SET_IMMUTABLE_WHEN_WAITING&#160;</td><td class="fielddoc"><p >Attempted to write to an event set, while a wait operation was pending on that event set. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a8f3a13ffefc4897da606c86e60a4422f" name="a18e13de77b119ea0f2be411490859482a8f3a13ffefc4897da606c86e60a4422f"></a>S_EVENT_SET_EVENT_ALREADY_EXISTS&#160;</td><td class="fielddoc"><p >Attempted to add an event into an event set, but that event already exists. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a96f464959b6ce918048a2167c23f1c0b" name="a18e13de77b119ea0f2be411490859482a96f464959b6ce918048a2167c23f1c0b"></a>S_EVENT_SET_EVENT_DOES_NOT_EXIST&#160;</td><td class="fielddoc"><p >Attempted to work with an event that does not exist in the event set. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482adccb025a96014a74a1435481ec2b58ac" name="a18e13de77b119ea0f2be411490859482adccb025a96014a74a1435481ec2b58ac"></a>S_EVENT_SET_DOUBLE_WAIT_OR_POLL&#160;</td><td class="fielddoc"><p >Attempted to wait on or poll an event set while already waiting on that event set. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a5cbb0762dc20632c76db479f40237492" name="a18e13de77b119ea0f2be411490859482a5cbb0762dc20632c76db479f40237492"></a>S_EVENT_SET_NO_EVENTS&#160;</td><td class="fielddoc"><p >Attempted to wait on an event set without specifying event on which to wait. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a3e273da0f7d2f231dbfaab8d07fd5ecd" name="a18e13de77b119ea0f2be411490859482a3e273da0f7d2f231dbfaab8d07fd5ecd"></a>S_EVENT_SET_RESULT_CHECK_WHEN_WAITING&#160;</td><td class="fielddoc"><p >Attempted to check wait results while still waiting. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a9a2cbc62120ca52c1f7e695b56b2bdcd" name="a18e13de77b119ea0f2be411490859482a9a2cbc62120ca52c1f7e695b56b2bdcd"></a>S_CONN_METADATA_TOO_LARGE&#160;</td><td class="fielddoc"><p >During connection user supplied metadata that is too large. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482ad7b8da59bb61205572fe985c29863e58" name="a18e13de77b119ea0f2be411490859482ad7b8da59bb61205572fe985c29863e58"></a>S_STATIC_OPTION_CHANGED&#160;</td><td class="fielddoc"><p >When setting options, tried to set an unchangeable (static) option. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482a5e0c2b54a5427bc09ecf0dee603ce450" name="a18e13de77b119ea0f2be411490859482a5e0c2b54a5427bc09ecf0dee603ce450"></a>S_OPTION_CHECK_FAILED&#160;</td><td class="fielddoc"><p >When setting options, at least one option's value violates a required condition on that option. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482ab92ec3b2b78d74acf0fda0786f601df5" name="a18e13de77b119ea0f2be411490859482ab92ec3b2b78d74acf0fda0786f601df5"></a>S_WAIT_INTERRUPTED&#160;</td><td class="fielddoc"><p >A blocking (<code>sync_</code>) or background-blocking (<code>async_</code>) operation was interrupted, such as by a signal. </p>
</td></tr>
<tr><td class="fieldname"><a id="a18e13de77b119ea0f2be411490859482ab835895723a7d71c964b84e0f0b78c3c" name="a18e13de77b119ea0f2be411490859482ab835895723a7d71c964b84e0f0b78c3c"></a>S_WAIT_USER_TIMEOUT&#160;</td><td class="fielddoc"><p >A blocking (<code>sync_</code>) or background-blocking (<code>async_</code>) operation timed out versus user-supplied time limit. </p>
</td></tr>
</table>

<p class="definition">Definition at line <a class="el" href="net__flow_2error_2error_8hpp_source.html#l00135">135</a> of file <a class="el" href="net__flow_2error_2error_8hpp_source.html">error.hpp</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="a6d35c37eb70a494bb27aa807c41de176" name="a6d35c37eb70a494bb27aa807c41de176"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6d35c37eb70a494bb27aa807c41de176">&#9670;&nbsp;</a></span>make_error_code()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a> flow::net_flow::error::make_error_code </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482">Code</a>&#160;</td>
          <td class="paramname"><em>err_code</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Given a <code>Code</code> <code>enum</code> value, creates a lightweight <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">flow::Error_code</a> (a/k/a <a class="el" href="namespaceboost_1_1system.html" title="We may add some ADL-based overloads into this namespace outside flow.">boost.system</a> <code>error_code</code>) representing that error. </p>
<p >This is needed to make the <code>boost::system::error_code::error_code&lt;Code&gt;()</code> template implementation work. Or, slightly more in English, it glues the (completely general) <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">flow::Error_code</a> to the (net_flow-specific) error code set <a class="el" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482" title="All possible errors returned (via flow::Error_code arguments) by flow::net_flow functions/methods.">flow::net_flow::error::Code</a>, so that one can implicitly covert from the latter to the former.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">err_code</td><td>The <code>enum</code> value. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>A corresponding <a class="el" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09" title="Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...">flow::Error_code</a>. </dd></dl>

<p class="definition">Definition at line <a class="el" href="net__flow_2error_2error_8cpp_source.html#l00093">93</a> of file <a class="el" href="net__flow_2error_2error_8cpp_source.html">error.cpp</a>.</p>

<p class="reference">References <a class="el" href="net__flow_2error_2error_8cpp_source.html#l00046">flow::net_flow::error::Category::S_CATEGORY</a>.</p>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Mar 28 2025 22:55:36 for Flow by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>
